﻿/*
 * Copyright © 2011 Tristan Reeves, treeves@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
using NUnit.Framework;
using Spring.Context.Support;
using Sprinkles.Tests.TestClasses;

namespace Sprinkles.Tests.UnitTests.ConstructorArgs
{
    [TestFixture]
    public class CreationTests_ManyArgs_Expression
    {
        private const string ROOT_HOST = "DummyHost_C3.Expression";
        private const int OFFSET = 1;

        [Test]
        public void Can_Call_1_Arg_Constructor()
        {
            var ctx = new XmlApplicationContext(@"config\ConstructionConfig1.xml");
            var obj = ctx[ROOT_HOST + ".1"] as ConstructorTest1;
            Assert.That(obj.X, Is.EqualTo(1 + OFFSET));
        }
        [Test]
        public void Can_Call_2_Arg_Constructor()
        {
            var ctx = new XmlApplicationContext(@"config\ConstructionConfig1.xml");
            var obj = ctx[ROOT_HOST + ".2"] as ConstructorTest1;
            Assert.That(obj.X, Is.EqualTo(1 + OFFSET));
            Assert.That(obj.O, Is.EqualTo("a"));
        }
        [Test]
        public void Can_Call_3_Arg_Constructor()
        {
            var ctx = new XmlApplicationContext(@"config\ConstructionConfig1.xml");
            var obj = ctx[ROOT_HOST + ".A"] as ConstructorTest1;
            Assert.That(obj.ThreeAndAbove.Count, Is.EqualTo(3));
            Assert.That(obj.ThreeAndAbove[0], Is.EqualTo(0 + OFFSET));
            Assert.That(obj.ThreeAndAbove[1], Is.EqualTo(1 + OFFSET));
            Assert.That(obj.ThreeAndAbove[2], Is.EqualTo(2 + OFFSET));
        }
        [Test]
        public void Can_Call_4_Arg_Constructor()
        {
            var ctx = new XmlApplicationContext(@"config\ConstructionConfig1.xml");
            var obj = ctx[ROOT_HOST + ".B"] as ConstructorTest1;
            Assert.That(obj.ThreeAndAbove.Count, Is.EqualTo(4));
            Assert.That(obj.ThreeAndAbove[0], Is.EqualTo(3 + OFFSET));
            Assert.That(obj.ThreeAndAbove[1], Is.EqualTo(4 + OFFSET));
            Assert.That(obj.ThreeAndAbove[2], Is.EqualTo(5 + OFFSET));
            Assert.That(obj.ThreeAndAbove[3], Is.EqualTo(6 + OFFSET));
        }
        [Test]
        public void Can_Call_5_Arg_Constructor()
        {
            var ctx = new XmlApplicationContext(@"config\ConstructionConfig1.xml");
            var obj = ctx[ROOT_HOST + ".C"] as ConstructorTest1;
            Assert.That(obj.ThreeAndAbove.Count, Is.EqualTo(5));
            Assert.That(obj.ThreeAndAbove[0], Is.EqualTo(7 + OFFSET));
            Assert.That(obj.ThreeAndAbove[1], Is.EqualTo(8 + OFFSET));
            Assert.That(obj.ThreeAndAbove[2], Is.EqualTo(9 + OFFSET));
            Assert.That(obj.ThreeAndAbove[3], Is.EqualTo(10 + OFFSET));
            Assert.That(obj.ThreeAndAbove[4], Is.EqualTo(11 + OFFSET));
        }
    }
}
